﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SharePointClientHelper
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSiteUrl.Text) && !string.IsNullOrEmpty(txtDomain.Text) && !string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                SPClientHelper spcHelper = SPClientHelper.SetSPClientHelper(txtSiteUrl.Text, txtDomain.Text, txtUserName.Text, txtPassword.Text);
                if (spcHelper == null)
                {
                    MessageBox.Show("Failed");
                    //this.DialogResult = System.Windows.Forms.DialogResult.Retry;
                }
                else
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Please provide all the fields");
            }
        }
    }
}
